set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
/* *******************************************************************
** DATE :
** Writer :
** Memo :
******************************************************************** */
CREATE PROCEDURE [dbo].[TSP_Popup_Modify]
(
	@IsTransaction	tinyint			= 0
,	@ErrorCode		int				= 0		OUTPUT
,	@ErrorMessage	nvarchar( 1000 )= ''	OUTPUT

,	@n4SeqNo	int	
,	@n4Width	int	= NULL	
,	@n4Height	int	= NULL	
,	@n4Top	int	= NULL	
,	@n4Left	int	= NULL	
,	@n1PopupType	tinyint	= NULL	
,	@strImageURL	varchar(200)	= NULL	
,	@strLinkURL	varchar(300)	= NULL	
,	@strHTML	nvarchar(2000)	= NULL	
,	@IsCookie	tinyint	= NULL	
,	@strManagerName	nvarchar(100)	= NULL
)
as
Set NOCOUNT ON

-- Frk Default Value
DECLARE @FrkDateNow DateTime
DECLARE @FrkRowCount int
DECLARE @FrkTranCount int
DECLARE @FrkErrorCode int
DECLARE @FrkErrorMessage nvarchar( 1000 )
Set @FrkDateNow = GetDate()
set @FrkTranCount = @@TRANCOUNT
-- Frk Check


If ( @IsTransaction = 0 )
Begin
	If ( @FrkTranCount < 1 )
	Begin
		Set @FrkErrorCode = -1
		Set @FrkErrorMessage = 'Transaction.'
		goto ERROR
	End
	Else If ( @FrkTranCount > 1 )
	Begin
		Set @FrkErrorCode = -2
		Set @FrkErrorMessage = 'Transaction.'
		goto ERROR
	End
End
Else
Begin
	If ( @FrkTranCount <> 0 )
	Begin
		Set @FrkErrorCode = -3
		Set @FrkErrorMessage = 'Transaction.'
		goto ERROR
	End
	Begin Tran
End

-- Implementation


UPDATE
	dbo.TB_Popup
SET
	n4Width = IsNull( @n4Width, n4Width )
,	n4Height = IsNull( @n4Height, n4Height )
,	n4Top = IsNull( @n4Top, n4Top )
,	n4Left = IsNull( @n4Left, n4Left )
,	n1PopupType = IsNull( @n1PopupType, n1PopupType )
,	strImageURL = IsNull( @strImageURL, strImageURL )
,	strLinkURL = IsNull( @strLinkURL, strLinkURL )
,	strHTML = IsNull( @strHTML, strHTML )
,	IsCookie = IsNull( @IsCookie, IsCookie )
,	strManagerName = IsNull( @strManagerName, strManagerName )
WHERE
	n4SeqNo = @n4SeqNo


-- Frk Error Check
SELECT
	@FrkErrorCode = @@ERROR
,	@FrkRowCount = @@RowCount

-- End

COMPLETE:
	If ( @IsTransaction <> 0 )
	Begin
		If ( @@TRANCOUNT = 1 )
		Begin
			Commit Tran
		End
	End
	SET @ErrorCode = 0
	SET @ErrorMessage = ''
	return 0
ERROR:
	If ( @IsTransaction <> 0 )
	Begin
		If ( @@TRANCOUNT = 1 )
		Begin
			Rollback Tran
		End
	End
	SET @ErrorCode = @FrkErrorCode
	SET @ErrorMessage = @FrkErrorMessage
	return @FrkErrorCode
